package com.ravi.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ravi.mapper.ItemTypeMapper;
import com.ravi.model.entity.ItemType;
import com.ravi.service.intf.ItemTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ItemTypeServiceImpl implements ItemTypeService {

	@Autowired
	private ItemTypeMapper itemTypeMapper;

	@Override
	public PageInfo<ItemType> listItemTypePage(Integer pageNum, Integer pageSize) {
		pageNum = (null == pageNum) || (pageNum <= 0) ? 1 : pageNum;
		PageHelper.startPage(pageNum, pageSize);
		PageHelper.orderBy("priority desc");
		List<ItemType> itemTypes = itemTypeMapper.getAll();
		return new PageInfo<ItemType>(itemTypes);
	}
}
